//
//  TeachClassPrivateTableViewCell.m
//  fitnessmanage
//
//  Created by wujian on 2018/1/24.
//  Copyright © 2018年 zongquankeji. All rights reserved.
//

#import "TeachClassPrivateTableViewCell.h"

@implementation TeachClassPrivateTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        /**
         课程名字
         */
        UIImageView *classImageView = [[UIImageView alloc] init];
        classImageView.layer.cornerRadius = 3;
        classImageView.layer.masksToBounds = YES;
        [self.contentView addSubview:classImageView];
        self.classImageView = classImageView;
        
        
        /**
         课程名字
         */
        UILabel *classNameLabel = [[UILabel alloc] init];
        classNameLabel.font = MidBigFont;
        classNameLabel.textColor = CSColorFromRGB(0x0a0a0a);
        [self.contentView addSubview:classNameLabel];
        self.classNameLabel = classNameLabel;
                                
        
        /**
         讲课老师
         */
        UILabel *teachLabel = [[UILabel alloc] init];
        teachLabel.font = MidFont;
        teachLabel.text = @"课程项目：";
        teachLabel.textColor = CSColorFromRGB(0x888888);
        [self.contentView addSubview:teachLabel];
        self.teachLabel = teachLabel;
        
        
        
        /**
         时间Label
         */
        UILabel *timeLabel = [[UILabel alloc] init];
        timeLabel.font = [UIFont boldSystemFontOfSize:15.0];
        timeLabel.textColor = CSColorFromRGB(0x323232);
        [self.contentView addSubview:timeLabel];
        self.timeLabel = timeLabel;
        
        
        UIButton *stateBtn = [[UIButton alloc] init];
        stateBtn.backgroundColor = ButtonBackGroundColor;
        stateBtn.contentEdgeInsets = UIEdgeInsetsMake(3, 5, 5, 3);
        stateBtn.layer.cornerRadius = 3;
        stateBtn.layer.masksToBounds = YES;
        [stateBtn setTitle:@"待上课"];
        [stateBtn setTitleColor:CSColorFromRGB(0x0a0a0a)];
        stateBtn.titleLabel.font = SmallFont;
        [self.contentView addSubview:stateBtn];
        self.stateBtn = stateBtn;
        
        UILabel *countLabel = [[UILabel alloc] init];
        countLabel.font = SmallFont;
        countLabel.textColor = CSColorFromRGB(0x0a0a0a);
        [self.contentView addSubview:countLabel];
        self.countLabel = countLabel;
        
        UILabel *countLabel1 = [[UILabel alloc] init];
        countLabel1.font = SmallFont;
        countLabel1.textColor = CSColorFromRGB(0xa5a5a5);
        countLabel1.text = @"人";
        [self.contentView addSubview:countLabel1];
        self.countLabel1 = countLabel1;
        
        [self setConstraints];
    }
    
    return self;
}


-(void)setConstraints{
    
    /**
     课程名字
     */
    [self.classImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.mas_equalTo(self.contentView).offset(15);
        
        make.height.width.mas_equalTo(80);
        
        make.bottom.mas_equalTo(self.contentView).offset(-15);
    }];
    
    /**
     课程名字
     */
    [self.classNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.classImageView).offset(10);
        
        make.left.mas_equalTo(self.classImageView.mas_right).offset(15);
    }];
    
    
    /**
     讲课老师
     */
    [self.teachLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.classImageView).offset(-10);
        
        make.left.mas_equalTo(self.classImageView.mas_right).offset(15);
    }];
    
    /**
     时间Label
     */
    [self.timeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.contentView).offset(17);
        
        make.right.mas_equalTo(self.contentView).offset(-20);
    }];
    
    [self.stateBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self.timeLabel);
        
        make.top.mas_equalTo(self.timeLabel.mas_bottom).offset(10);
    }];
    
    
    [self.countLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.stateBtn.mas_bottom).offset(10);
        
        make.right.mas_equalTo(self.countLabel1.mas_left);
    }];
    
    [self.countLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self.timeLabel);
        
        make.bottom.mas_equalTo(self.countLabel);
    }];
}

- (void)drawRect:(CGRect)rect
{
    CGContextRef context =UIGraphicsGetCurrentContext();
    
    CGContextBeginPath(context);
    
    CGContextSetLineWidth(context,1.0);//线宽度
    
    CGContextSetStrokeColorWithColor(context,LineBackGroundColor.CGColor);
    
    CGContextMoveToPoint(context,0,rect.size.height);
    
    CGContextAddLineToPoint(context,SCREEN_WIDTH,rect.size.height);
    
    CGContextStrokePath(context);
}

@end
